<?php
/**
 * Created by viva.
 * User: xj
 * Tel:  13675170078
 * Date: 2015/6/10
 * Time: 14:58
 */
namespace Admin\Controller;

class UserController extends CommonController
{

    public function login()
    {
        if(session('user_data')) {
            $this->success('登录成功',U('Ad/adList'));
        }
        else
        $this->display();
    }
    public function checkLogin()
    {
        $userModel=D('User');
        $result=$userModel->checkLogin(I('user_name'),I('password'));
       switch($result)
       {
           case 1:
               $this->success('登录成功',U('Ad/adList'));
               break;

           case 0:
               $this->error('登录失败，密码错误');
               break;
           case -1:
               $this->error('登录失败，不存在的账号');
               break;
       }

    }
    public function logOut()
    {
        session(null);
        $this->success('您已经成功退出登录',U('User/login'));
    }
}